
import Vue from 'vue'
import VueRouter from 'vue-router'
import LisRoutes from './LIS'
import MngRoutes from './MNG'
import ReqRoutes from './REQ'
import SmpRoutes from './SMP'
import ErrRoutes from './404'
Vue.use(VueRouter)
// 解决ElementUI导航栏中的vue-router重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

// console.log(originalPush);


const routes = [
  {
    path: '/',
    redirect: '/dashboard',
  },
  {
    path: '/',
    component: () =>
      import('../components/common/Home.vue'),
    meta: {
      title: '自述文件',
    },
    children: [
      {
        path: '/dashboard',
        component: () =>
          import('../components/page/Dashboard.vue'),
        meta: {
          title: '首页',
        },
      },
      {
        path: '/personalhomepage',
        component: () =>
          import('../components/page/personalhomepage.vue'),
        meta: {
          title: '个人主页',
        },
      },
      {
        path: '/msgcenter_page',
        component: () =>
          import('../components/page/msgcenter_page.vue'),
        meta: {
          title: '消息中心',
        },
      },
      {
        path: '/showlog',
        component: () =>
          import('../components/page/showlog.vue'),
        meta: {
          title: '查看日志',
        },
      },
      {
        path: '/upgradelog',
        component: () =>
          import('../components/page/upgradelog.vue'),
        meta: {
          title: '更新日志',
        },
      },
      ...LisRoutes,
      ...MngRoutes,
      ...ReqRoutes,
      ...SmpRoutes,
      ...ErrRoutes
    ]
  },
  {
    path: '/login',
    component: () =>
      import('../components/page/Login.vue'),
  },
  {
    path: '/REQ130',
    component: () =>
      import('../components/page/REQ/REQ1/REQ130.vue'),
  },
  {
    path: '*',
    redirect: '/404',
  },
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
